﻿using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using Hicap.AuthorizationServer.Core.Models.Other;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Hicap.AuthorizationServer.Core.Models
{
    public class User : FullAuditedEntity, IEntity
    {
        #region Property

        public bool IsActive { get; set; } = true;

        /// <summary>
        /// 用户id(唯一)
        /// </summary>
        [Required]
        [StringLength(EntityLengthConst.ShortCode)]
        public string UserCode { get; set; }

        /// <summary>
        /// 用户名(别名，可与id相同)
        /// </summary>
        [Required]
        [StringLength(EntityLengthConst.ShortName)]
        public string UserName { get; set; }

        /// <summary>
        /// 用户真实姓名
        /// </summary>
        [StringLength(EntityLengthConst.ShortName)]
        public string UserRealName { get; set; }

        /// <summary>
        /// 用户备注、说明
        /// </summary>
        [StringLength(EntityLengthConst.Describe)]
        public string UserRemarks { get; set; }

        /// <summary>
        /// 当前密码
        /// </summary>
        /// <remarks>
        ///     近三次密码不能相同(管理员重置不受此限)
        /// </remarks>
        public string CurPassword { get; set; }

        /// <summary>
        /// 上次密码
        /// </summary>
        public string LastPassword { get; set; }

        /// <summary>
        /// 上上次密码
        /// </summary>
        public string BeforeLastPassword { get; set; }

        /// <summary>
        /// 性别
        /// </summary>
        [StringLength(EntityLengthConst.Type)]
        public string Gender { get; set; }

        /// <summary>
        /// 年龄
        /// </summary>
        public int? Age { get; set; }

        /// <summary>
        /// 联系方式(联系人、联系电话、联络住址等)
        /// </summary>
        [StringLength(EntityLengthConst.LongName)]
        public string Contact { get; set; }

        /// <summary>
        /// 邮箱
        /// </summary>
        [EmailAddress]
        public string Email { get; set; }

        /// <summary>
        /// 住址
        /// </summary>
        [StringLength(EntityLengthConst.LongName)]
        public string Address { get; set; }

        /// <summary>
        /// 电话号码1(固定或移动1)
        /// </summary>
        [StringLength(EntityLengthConst.LongCode)]
        public string TelNumber { get; set; }

        /// <summary>
        /// 电话号码2(移动2)
        /// </summary>
        [StringLength(EntityLengthConst.LongCode)]
        public string TelNumberExt { get; set; }

        /// <summary>
        /// 级别--用于积分系统等其他用途
        /// </summary>
        public int? Level { get; set; }

        /// <summary>
        /// 优先级--用于抢购等需排队场景
        /// </summary>
        public int? Priority { get; set; }

        /// <summary>
        /// The last time this user entered to the system.
        /// </summary>
        public DateTime? LastLoginTime { get; set; }

        [ForeignKey("Company")]
        public int? SubordinateCompanyId { get; set; }

        public virtual Company SubordinateCompany { get; set; }

        #endregion Property
    }
}